package com.homework;

public class Rectangle {
    private int length;
    private int width;

    public Rectangle(int length, int width) {//构造器
        this.length = length;
        this.width = width;


    }

    public int getArea() {
        return length * width;
    }

    public int getPer() {
        return 2 * (length + width);
    }

    public void showAll() {
        System.out.println("矩形的长为：" + length + "\n矩形的宽为：" + width + "\n矩形的面积为：" + getArea() + "\n矩形的周长为：" + getPer());
    }
}
    class RectangleDemo{
        public static void main(String[] args) {
            Rectangle rectangle = new Rectangle(3,4);
            rectangle.showAll();
        }
    }


